<Query Kind="Program" />

void Main()
{
	Context context = new Context(new ConcreteStateA());
	context.Condition = 1;
	context.Request();
	context.Condition = 2;
	context.Request();
}

abstract class State{
	public abstract void Handle();
}

class ConcreteStateA : State
{
	public override void Handle()
	{
		Console.WriteLine("Handle() in A");
	}
}

class ConcreteStateB : State
{
	public override void Handle()
	{
		Console.WriteLine("Handle() in B");
	}
}

class Context
{
	public State State { get; set; }
	public int Condition {get;set;}
	public Context(State state){
		State = state;
	}
	
	public void Request(){
		ChangeState();
		State.Handle();
	}
	public void ChangeState(){
		if(Condition == 1){
			State = new ConcreteStateA();
		} else if(Condition == 2){
			State = new ConcreteStateB();
		}
	}
}